package com.scm.converter;


import com.scm.dto.req.order.OrderBeanReq;
import com.scm.dto.req.supply.ScmSupplyQuotationDetailReq;
import com.scm.dto.req.supply.ScmSupplyQuotationReq;
import com.scm.dto.resp.supply.ScmSupplyQuotationDetailResp;
import com.scm.persist.model.ScmSupplyQuotation;
import com.scm.persist.model.ScmSupplyQuotationDetail;
import org.apache.commons.compress.utils.Lists;
import org.springframework.util.CollectionUtils;

import java.util.List;
import java.util.stream.Collectors;

/**
 * @Comment：
 * @Author: 邹渺
 * @Date: 2024/5/18
 * @Time: 上午10:42
 */
public class SupplyConverter {
    public static List<ScmSupplyQuotationDetailResp> toScmSupplyQuotationDetailResp(List<ScmSupplyQuotationDetail> scmSupplyQuotationDetails){
        List<ScmSupplyQuotationDetailResp> list = Lists.newArrayList();
        if(CollectionUtils.isEmpty(scmSupplyQuotationDetails)){

            return list;
        }
        list = scmSupplyQuotationDetails.stream().map(SupplyConverter::toScmSupplyQuotationDetailResp).collect(Collectors.toList());
        return list;
    }

    public static ScmSupplyQuotationDetailResp toScmSupplyQuotationDetailResp(ScmSupplyQuotationDetail scmSupplyQuotationDetail) {
        if (scmSupplyQuotationDetail == null) {
            return null;
        }
        ScmSupplyQuotationDetailResp scmSupplyQuotationDetailResp = new ScmSupplyQuotationDetailResp();
        scmSupplyQuotationDetailResp.setSupplyQuotationId(scmSupplyQuotationDetail.getSupplyQuotationId());
        scmSupplyQuotationDetailResp.setProductId(scmSupplyQuotationDetail.getProductId());
        scmSupplyQuotationDetailResp.setProductCode(scmSupplyQuotationDetail.getProductCode());
        scmSupplyQuotationDetailResp.setProductName(scmSupplyQuotationDetail.getProductName());
        scmSupplyQuotationDetailResp.setProductUnit(scmSupplyQuotationDetail.getProductUnit());
        scmSupplyQuotationDetailResp.setProductSpec(scmSupplyQuotationDetail.getProductSpec());
        scmSupplyQuotationDetailResp.setProductCount(scmSupplyQuotationDetail.getProductCount());
        scmSupplyQuotationDetailResp.setPrice(scmSupplyQuotationDetail.getPrice());
        scmSupplyQuotationDetailResp.setRemark(scmSupplyQuotationDetail.getRemark());
        scmSupplyQuotationDetailResp.setTaxRate(scmSupplyQuotationDetail.getTaxRate());
        scmSupplyQuotationDetailResp.setDiscountRate(scmSupplyQuotationDetail.getDiscountRate());
        scmSupplyQuotationDetailResp.setAmt(scmSupplyQuotationDetail.getAmt());

        // Not mapped ScmSupplyQuotationDetail fields:
        // id
        // tenantId
        // createTime
        // createUser
        // updateTime
        // updateUser
        return scmSupplyQuotationDetailResp;
    }


    public static ScmSupplyQuotation toScmSupplyQuotation(ScmSupplyQuotationReq scmSupplyQuotationReq) {
        if (scmSupplyQuotationReq == null) {
            return null;
        }
        ScmSupplyQuotation scmSupplyQuotation = new ScmSupplyQuotation();
        scmSupplyQuotation.setId(scmSupplyQuotationReq.getId());
        scmSupplyQuotation.setBillNo(scmSupplyQuotationReq.getBillNo());
        scmSupplyQuotation.setBillDate(scmSupplyQuotationReq.getBillDate());
        scmSupplyQuotation.setSubject(scmSupplyQuotationReq.getSubject());
        scmSupplyQuotation.setSupplierName(scmSupplyQuotationReq.getSupplierName());
        scmSupplyQuotation.setBillType(scmSupplyQuotationReq.getBillType());
        scmSupplyQuotation.setDeliveryTime(scmSupplyQuotationReq.getDeliveryTime());
        scmSupplyQuotation.setDeliveryPlace(scmSupplyQuotationReq.getDeliveryPlace());
        scmSupplyQuotation.setContact(scmSupplyQuotationReq.getContact());
        scmSupplyQuotation.setPhone(scmSupplyQuotationReq.getPhone());
        scmSupplyQuotation.setEmail(scmSupplyQuotationReq.getEmail());

        // Not mapped ScmSupplyQuotationReq fields:
        // list

        // Not mapped ScmSupplyQuotation fields:
        // id
        // tenantId
        // createTime
        // createUser
        // updateTime
        // updateUser
        return scmSupplyQuotation;
    }
    public static List<ScmSupplyQuotationDetail> toScmSupplyQuotationDetail(List<ScmSupplyQuotationDetailReq> scmSupplyQuotationDetailReq){
        List<ScmSupplyQuotationDetail> list = Lists.newArrayList();
        if(CollectionUtils.isEmpty(scmSupplyQuotationDetailReq)){
            return list;
        }
        list = scmSupplyQuotationDetailReq.stream().map(SupplyConverter::toScmSupplyQuotationDetail).collect(Collectors.toList());
        return list;
    }
    public static ScmSupplyQuotationDetail toScmSupplyQuotationDetail(ScmSupplyQuotationDetailReq scmSupplyQuotationDetailReq) {
        if (scmSupplyQuotationDetailReq == null) {
            return null;
        }
        ScmSupplyQuotationDetail scmSupplyQuotationDetail = new ScmSupplyQuotationDetail();
        scmSupplyQuotationDetail.setSupplyQuotationId(scmSupplyQuotationDetailReq.getSupplyQuotationId());
        scmSupplyQuotationDetail.setProductId(scmSupplyQuotationDetailReq.getProductId());
        scmSupplyQuotationDetail.setProductCode(scmSupplyQuotationDetailReq.getProductCode());
        scmSupplyQuotationDetail.setProductName(scmSupplyQuotationDetailReq.getProductName());
        scmSupplyQuotationDetail.setProductUnit(scmSupplyQuotationDetailReq.getProductUnit());
        scmSupplyQuotationDetail.setProductSpec(scmSupplyQuotationDetailReq.getProductSpec());
        scmSupplyQuotationDetail.setProductCount(scmSupplyQuotationDetailReq.getProductCount());
        scmSupplyQuotationDetail.setPrice(scmSupplyQuotationDetailReq.getPrice());
        scmSupplyQuotationDetail.setRemark(scmSupplyQuotationDetailReq.getRemark());
        scmSupplyQuotationDetail.setTaxRate(scmSupplyQuotationDetailReq.getTaxRate());
        scmSupplyQuotationDetail.setDiscountRate(scmSupplyQuotationDetailReq.getDiscountRate());
        scmSupplyQuotationDetail.setAmt(scmSupplyQuotationDetailReq.getAmt());

        // Not mapped ScmSupplyQuotationDetail fields:
        // id
        // tenantId
        // createTime
        // createUser
        // updateTime
        // updateUser
        return scmSupplyQuotationDetail;
    }
}
